/**
 * Copyright 2010 Tristan Slominski
 *
 * Licensed under the MIT License (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.opensource.org/licenses/mit-license.php
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mindash.handlebars.client.views;

import com.google.gwt.user.client.ui.Widget;
import com.mindash.handlebars.client.presenters.Presenter;

/**
 * @author Tristan Slominski
 * 
 */
public interface View {

  /**
   * Asks the presenter to bind child views to this view.
   */
  public void bindView();

  /**
   * <p>
   * Creates and binds the widget using UiBinder.
   * </p>
   * 
   * <p>
   * The simplest {@code createAndBind()} is:
   * 
   * <code><pre>
   * &#064;Override
   * public Widget createAndBind() {
   *   bindView();
   *   initWidget(&lt;UiBinder&gt;.createAndBindUi(this));
   *   return this;
   * }
   * </pre></code>
   * 
   * where you replace &lt;UiBinder&gt; with the view's specific binder
   * interface.
   * </p>
   * 
   * @return widget ready to attach to other widgets or root panel
   */
  public Widget createAndBind();

  /**
   * @return the adapter this view uses
   */
  public int getAdapter();

  /**
   * @return the presenter this view is coupled with
   */
  public Presenter getPresenter();

  /**
   * @return {@code true} if dto presenter is loading, {@code false} otherwise
   */
  public boolean isLoading();

  /**
   * Conducts any processing on the view after it is created via
   * {@link #createAndBind()}
   */
  public void postProcessView();

  /**
   * Sets this view's adapter.
   * 
   * @param adapter the adapter to set
   */
  public void setAdapter(int adapter);

  /**
   * Sets this view's presenter.
   * 
   * @param presenter the presenter this view is coupled with
   */
  public void setPresenter(Presenter presenter);

}
